<template>
  <div class="app-container">
    <div class="searchBox">
      <el-form :inline="true" :model="search" ref="searchForm">
        <el-form-item label="项目/合同：" prop="name">
          <el-input v-model="search.name" placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-form-item style="margin-top: -2px">
          <el-button type="primary" @click="searchQuery">查询</el-button>
          <el-button type="info" @click="search = {};searchQuery()">重置</el-button>
        </el-form-item>
      </el-form>
    </div>

    <qm-table
      ref="fundsTable"
      keyProp="fundsId"
      menuType="text"
      :data="query"
      :showView="false"
      :showEdit="false"
      :showDelete="false"
      :showCheckbox="false"
      :showToolbar="false"
      :menuOptions="{width:'80px'}"
    >
      <qm-table-column field="项目名称">项目名称</qm-table-column>
      <qm-table-column v-if="hasProDirFeeField" field="项目总监费用">项目总监费用</qm-table-column>
      <qm-table-column field="项目成本">项目成本</qm-table-column>
      <qm-table-column field="项目费用">项目费用</qm-table-column>
      <qm-table-column field="项目差旅费">项目差旅费</qm-table-column>
      <template v-slot:moreBtn="{ row }">
        <el-button @click="history(row.fundsId)" size="mini" type="text">历史记录</el-button>
      </template>
    </qm-table>
  </div>
</template>

<script>
import Controller from "@/libs/framework/controller";
import request from "@/utils/request";
import _ from "lodash";

export default class Instance extends Controller {
  onBeforeInit() {
    this.urls = {
      query: "/eip/fundsx/projectFundsList",
    };
  }
  onBeforeSave(postModel) {
    return true;
  }
  onAfterQuery(type, isSuccess, result) {
    if (type === "list" && isSuccess) {
      if (result && Array.isArray(result.data) && result.data.length > 0) {
        if (Object.keys(result.data[0]).includes("项目总监费用")) {
          this.vm.hasProDirFeeField = true;
          return result;
        }
      }
    }
    this.vm.hasProDirFeeField = false;
    return result;
  }
  mixin() {
    return {
      data() {
        return {
          projectOptions: [],
          hasProDirFeeField: false,
        };
      },
      methods: {
        history(value) {
          this.$root.openModal(
            "/smartform/hub/ProjectFundsHistoryList?fundsId=" + value,
            null,
            null
          );
        },
      },
    };
  }
}
</script>

<style scoped lang="scss">
</style>
